/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   edw_types.h
 * Author: edw200
 *
 * Created on 2018年3月29日, 上午10:53
 */

#ifndef XAG_TYPES_H
#define XAG_TYPES_H

#ifdef __cplusplus
extern "C"
{
#endif

typedef unsigned char           XAG_U8;
typedef unsigned short          XAG_U16;
typedef unsigned int            XAG_U32;

typedef signed char             XAG_S8;
typedef short                   XAG_S16;
typedef int                     XAG_S32;

typedef float                   XAG_F32;
typedef double                  XAG_F64;

#ifdef _WIN32
    typedef __int64             XAG_U64;
    typedef __int64             XAG_S64;
#else
    typedef unsigned long long  XAG_U64;
    typedef long long           XAG_S64;
#endif

#ifdef __x86_64__
    typedef unsigned int        XAG_U32L;
    typedef int                 XAG_S32L;
#else
    typedef unsigned long       XAG_U32L;
    typedef long                XAG_S32L;
#endif
    
typedef char                    XAG_CHAR;
#define XAG_VOID                void
#define XAG_BOOL                bool
#define XAG_STRING              string 

#define XAG_SUCCESS              0
#define XAG_FAILURE             (-1)
#define XAG_MAPERR              (-2)
#define XAG_TIMEOUT             (-3)
#define XAG_NOMEM               (-4)
#define XAG_FIFO_FULL           (-5)
#define XAG_FIFO_EMPTY          (-6)
#define XAG_NOINIT              (-7)
#define XAG_ERRIOCTL            (-8)
#define XAG_ERRIO               (-9)
#define XAG_NULLPOINT			(-10)


#define XAG_SAFE_ALLOCA_STRING(...) \
({ \
    XAG_CHAR* __csString; \
    XAG_S32 __s32Len; \
    __s32Len = snprintf(NULL, 0, ##__VA_ARGS__); \
    __csString = (XAG_CHAR*)alloca(__s32Len); \
    sprintf(__csString, ##__VA_ARGS__); \
    __csString; \
})

#ifdef __cplusplus
}
#endif

#endif /* XAG_TYPES_H */

